package main

import (
	"fmt"
	_ "func/initlib1"
	_ "func/initlib2"
)

// go函数返回多个值
func swap(x, y string) (string, string) {
	return y, x
}
func main() {
	//a, b := swap("Tom", "Alice")
	//fmt.Println(a, b)
	//fmt.Println("main main")
	var x, y = 1, 2
	swap1(x, y)
	fmt.Println(x, y)
	swap2(&x, &y)
	fmt.Println(x, y)
}

func init() {
	fmt.Println("main init")
}

// 值传递
func swap1(x int, y int) {
	var temp int
	temp = x
	x = y
	y = temp
}

// 引用传递
func swap2(x *int, y *int) {
	// *x, *y = *y, *x
	temp := *x
	*x = *y
	*y = temp
}
